package com.huawei.hwCloudJs.service.hms;

import com.huawei.hms.api.HuaweiApiClient;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

public final class c {
    private static c a = new c();
    private final Map<String, Map<String, HuaweiApiClient>> b = new HashMap();

    private c() {
    }

    public static c a() {
        return a;
    }

    public HuaweiApiClient a(String str, String str2) {
        HuaweiApiClient huaweiApiClient;
        synchronized (this.b) {
            Map map = (Map) this.b.get(str);
            if (map != null) {
                huaweiApiClient = (HuaweiApiClient) map.get(str2);
            } else {
                huaweiApiClient = null;
            }
        }
        return huaweiApiClient;
    }

    public void a(String str) {
        synchronized (this.b) {
            Map map = (Map) this.b.remove(str);
            if (map != null) {
                for (Entry value : map.entrySet()) {
                    ((HuaweiApiClient) value.getValue()).disconnect();
                }
            }
        }
    }

    public void a(String str, String str2, HuaweiApiClient huaweiApiClient) {
        synchronized (this.b) {
            Map map = (Map) this.b.get(str);
            if (map == null) {
                map = new HashMap();
                this.b.put(str, map);
            }
            map.put(str2, huaweiApiClient);
        }
    }
}
